OpenRoads Designer CONNECT Edition SDK Help

Print alignment stationing

Alignments can have a stationing. Stationing is naming or labeling of points or regions along an alignment. The below code shows how to get the stationing from alignment and print the position of stationing points.

Example


internal void PrintAlignmentStationing(Alignment alignment)
        {
            //Get active dgn model 
            Bentley.DgnPlatformNET.DgnModel activeModel = Bentley.MstnPlatformNET.Session.
Instance.GetActiveDgnModel();
            //Create new object of StationingFormatter
            Bentley.CifNET.GeometryModel.SDK.StationingFormatter sformatter = new 
StationingFormatter(alignment);
            //Get StationFormatSettings from active dgn model 
            Bentley.CifNET.GeometryModel.SDK.StationFormatSettings settings = StationFormatSettings.
GetStationFormatSettingsForModel(activeModel);

            //Get StationList from alignment
            IEnumerable<double> stationList = alignment.Stationing.GetStationList(false, 200, false);

            //Get Linear points for all stations available in station list 
            LinearPointCollection ptCollection = alignment.LinearGeometry.StrokeByDistances
(stationList.ToArray());
            DPoint3d[] stationPointsArray = ptCollection.GetVertices();
            //Iterate over each point to get station properties
            foreach (DPoint3d point in stationPointsArray)
            {
                //Get station point
                string stationStr = "";
                Bentley.CifNET.LinearGeometry.LinearPoint stationPoint = alignment.LinearGeometry.
ProjectPointOnPerpendicular(point);
                double startStationNum = stationPoint.DistanceOnExtension + stationPoint.DistanceAlong;

                //Format station point based on settings available
                sformatter.FormatStation(ref stationStr, startStationNum, settings);
                double X = 0.0, Y = 0.0, Z = 0.0;
                point.Get(out X, out Y, out Z);
                string x = FormatForDisplay.Coordinate(X);
                string y = FormatForDisplay.Coordinate(Y);
                string xy = "( " + x + ", " + y + " )";

                //Print coordinates of station point and distance 
                System.Diagnostics.Debug.Print("Station Name: "+ stationStr);
                System.Diagnostics.Debug.Print("(x, y): "+ xy);

                System.Diagnostics.Debug.Print("Distance: "+ stationPoint.DistanceAlong);            
												}
        }

To get the StationList from alignment, stationing should be added to alignment using AddStationing(). The above code prints the Station name, and station coordinates.

Output

The above function PrintAlignmentStationing() generates output in below format

Station Name: 0+00.00
(x, y): ( 2319794.829', 760500.992' )
Distance: 0
Station Name: 6+56.17
(x, y): ( 2320449.159', 760451.937' )
Distance: 200.000000000033
Station Name: 13+12.33
(x, y): ( 2321103.490', 760402.882' )
Distance: 399.999999999951
Station Name: 19+68.50
(x, y): ( 2321757.820', 760353.827' )
Distance: 599.999999999984
Station Name: 26+24.67
(x, y): ( 2322412.151', 760304.772' )
Distance: 800.000000000019